#include <iostream>
using namespace std;

char* rev(char* str)
{
    if( str == 0)
        return 0;
    int len = strlen(str);
    for(int i = 0; i < len/2; ++i)
    {
        char temp;
        temp = str[i];
        str[i] = str[len-i-1];
        str[len-i-1] = temp;
    }
    return str;
}
int main()
{
    char str1[] = "abcde";
    char str2[] = "abcd";
    char* str3 = 0;
    
    cout <<  rev(str1) << endl;
    cout <<  rev(str2) << endl;
    cout <<  rev(str3) << endl;
}
